// lua.hpp
// Lua header files for C++
// <<extern "C">> not supplied automatically because Lua also compiles as C++




#ifdef _WIN64
    //#pragma comment(lib, "D:/MyYun/SDK/hcSDK/other/lua/lua53-64.lib")

extern "C" {
	#include "lua.h"
	#include "lualib.h"
	#include "lauxlib.h"
	}
	#pragma comment(lib, "D:/MyYun/SDK/hcSDK/other/lua/lua53-64.lib")

#else
    extern "C" {
    #include "lua.h"
    #include "lualib.h"
    #include "lauxlib.h"
    }
    #pragma comment(lib, "D:/MyYun/SDK/hcSDK/other/lua/lua53-32.lib")
#endif


#ifdef _WIN64



	/*
    #define LUA_TNONE		(-1)

    #define LUA_TNIL		0
    #define LUA_TBOOLEAN		1
    #define LUA_TLIGHTUSERDATA	2
    #define LUA_TNUMBER		3
    #define LUA_TSTRING		4
    #define LUA_TTABLE		5
    #define LUA_TFUNCTION		6
    #define LUA_TUSERDATA		7
    #define LUA_TTHREAD		8
    #define LUA_NUMTAGS		9

// thread status
#define LUA_OK		0
#define LUA_YIELD	1
#define LUA_ERRRUN	2
#define LUA_ERRSYNTAX	3
#define LUA_ERRMEM	4
#define LUA_ERRGCMM	5
#define LUA_ERRERR	6





    #define LUA_API		extern

    #define LUA_INTEGER		__int64
    #define LUA_NUMBER	double


    typedef struct lua_State lua_State;
    typedef LUA_INTEGER lua_Integer;
    typedef LUA_NUMBER lua_Number;



//typedef void (WINAPI *setvalue)(int);
typedef void (WINAPI* lua_close_p)(lua_State* L);
lua_close_p lua_close;

typedef void        (WINAPI* lua_pushnil_p)(lua_State* L);
lua_pushnil_p lua_pushnil;
typedef void        (WINAPI* lua_pushnumber_p)(lua_State* L, lua_Number n);
lua_pushnumber_p lua_pushnumber;
typedef void        (WINAPI* lua_pushinteger_p)(lua_State* L, lua_Integer n);
lua_pushinteger_p lua_pushinteger;
typedef const char* (WINAPI* lua_pushlstring_p)(lua_State* L, const char* s, size_t len);
lua_pushlstring_p lua_pushlstring;
typedef const char* (WINAPI* lua_pushstring_p)(lua_State* L, const char* s);
lua_pushstring_p lua_pushstring;
typedef const char* (WINAPI* lua_pushvfstring_p)(lua_State* L, const char* fmt, va_list argp);
lua_pushvfstring_p lua_pushvfstring;

typedef int   (WINAPI*lua_gettop_p)(lua_State* L);
lua_gettop_p lua_gettop;

typedef lua_Number(WINAPI*lua_tonumberx_p) (lua_State* L, int idx, int* isnum);
lua_tonumberx_p lua_tonumberx;



typedef int             (WINAPI *lua_toboolean_p)(lua_State* L, int idx);
lua_toboolean_p lua_toboolean;

typedef const char* (WINAPI *lua_tolstring_p)(lua_State* L, int idx, size_t* len);
lua_tolstring_p lua_tolstring;

typedef size_t(WINAPI*lua_rawlen_p) (lua_State* L, int idx);
lua_rawlen_p lua_rawlen;

typedef int (WINAPI *luaL_error_p)(lua_State* L, const char* fmt, ...);
luaL_error_p luaL_error;

typedef void  (WINAPI *lua_pushboolean_p)(lua_State* L, int b);
lua_pushboolean_p lua_pushboolean;

typedef lua_State* (WINAPI *luaL_newstate_p)(void);
luaL_newstate_p luaL_newstate;

typedef void  (WINAPI*lua_setglobal_p)(lua_State* L, const char* name);
lua_setglobal_p lua_setglobal;

typedef int (*lua_CFunction) (lua_State* L);
typedef void  (WINAPI* lua_pushcclosure_p)(lua_State* L, lua_CFunction fn, int n);
lua_pushcclosure_p  lua_pushcclosure;
//typedef void  (WINAPI* lua_pushcclosure_p)(lua_State* L, lua_CFunction fn, int n);
//lua_pushcclosure_p lua_pushcclosure;

typedef lua_Integer(WINAPI*luaL_checkinteger_p) (lua_State* L, int arg);
luaL_checkinteger_p  luaL_checkinteger;

typedef int             (WINAPI* lua_type_p)(lua_State* L, int idx);
lua_type_p  lua_type;

typedef void  (WINAPI* lua_settop_p)(lua_State* L, int idx);
lua_settop_p  lua_settop;

typedef int (WINAPI *luaL_loadstring_p)(lua_State* L, const char* s);
luaL_loadstring_p luaL_loadstring;

typedef void (WINAPI* luaL_openlibs_p)(lua_State* L);
luaL_openlibs_p luaL_openlibs;


#define LUA_KCONTEXT	ptrdiff_t
typedef LUA_KCONTEXT lua_KContext;
typedef int (WINAPI *lua_KFunction) (lua_State* L, int status, lua_KContext ctx);



typedef int   (WINAPI* lua_pcallk_p)(lua_State* L, int nargs, int nresults, int errfunc,
    lua_KContext ctx, lua_KFunction k);
lua_pcallk_p  lua_pcallk;



#define lua_pcall(L,n,r,f)	lua_pcallk(L, (n), (r), (f), 0, NULL)

#define lua_tonumber(L,i)	lua_tonumberx(L,(i),NULL)
#define lua_tostring(L,i)	lua_tolstring(L, (i), NULL)
#define lua_register(L,n,f) (lua_pushcfunction(L, (f)), lua_setglobal(L, (n)))
//#define lua_pushcfunction(L,f)	lua_pushcclosure(L, (f), 0)

void WINAPI lua_pushcfunction(lua_State* L, lua_CFunction fn)
{
    lua_pushcclosure(L, fn, 0);
}

#define luaL_dostring(L, s) \
	(luaL_loadstring(L, s) || lua_pcall(L, 0, LUA_MULTRET, 0))

#define lua_pop(L,n)		lua_settop(L, -(n)-1)




void init()
{
    HMODULE hDll = LoadLibraryA("lua53-64.dll");
    if (hDll == NULL)
        return ;

    lua_close = (lua_close_p)GetProcAddress(hDll, "lua_close");
    lua_pushinteger = (lua_pushinteger_p)GetProcAddress(hDll, "lua_pushinteger");
    lua_gettop = (lua_gettop_p)GetProcAddress(hDll, "lua_gettop");
    //lua_tonumberx = (lua_tonumberx_p)GetProcAddress(hDll, "lua_tonumberx");


    GetProcAddress(hDll, "lua_close");
    GetProcAddress(hDll, "lua_close");
    GetProcAddress(hDll, "lua_close");
    GetProcAddress(hDll, "lua_close");
    GetProcAddress(hDll, "lua_close");
    GetProcAddress(hDll, "lua_close");
    GetProcAddress(hDll, "lua_close");
    GetProcAddress(hDll, "lua_close");
    GetProcAddress(hDll, "lua_close");
    GetProcAddress(hDll, "lua_close");
}
*/

#endif